<?php defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
/**
 * Title          mobile upload lib
 *
 * @package        appworkz
 * Location        application/frontend/libraries/upload_lib
 *
 * @author         Ruwan Pathmalal 
 * @copyright      appworkz
 * Description     appworkz centralize file upload lib
 *
 **/

class upload_lib {
    //put your code here
    protected $ci;
    
    protected $upload_config = array();
    protected $media_path;
    
	public function __construct() {
		$this->ci =& get_instance();
		$this->ci->load->library('util/Image_upload');
	}

	public function upload(){
		$allowed_types = array(1=>'profile',2=>'billboard');
		$type = $this->ci->input->post('type');
		$feild_name = 'upfile';
		if(array_key_exists(intval($type), $allowed_types)){
			$method = $allowed_types[$type].'_image_upload';
			$data['feild_name'] = $feild_name;
			$result = $this->ci->image_upload->$method($data);
			echo json_encode($result,true);
			exit;
		}else{
			echo json_encode(array('status'=>0,'message'=>'Invalid upload type'));
			exit;
		}
	}
    
}